class Solution {
public:
    int maxScoreSightseeingPair(vector<int>& nums)
    {
        int ans = 0;
        //nums[i] + nums[j] - (j - i);
        int n = nums.size();
        int mx = nums[0];
        for (int i = 1; i < n; i++)
        {
            ans = max(ans, mx + nums[i] - i);
            mx = max(mx, nums[i] + i);
        }
        return ans;
    }
};